summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorliamwhite <liamwhite@users.noreply.github.com>2023-06-28 02:50:06 +0200
committerGitHub <noreply@github.com>2023-06-28 02:50:06 +0200
commit0b2798be276941fb5ee9df346b5a566c29cea4ed (patch)
tree370eb6fd83bf86a050e2cbc9d28abc7ccf3cc8f9
parentMerge pull request #10931 from german77/clang (diff)
parentsettings: Clean up includes (diff)
downloadyuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.tar
yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.tar.gz
yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.tar.bz2
yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.tar.lz
yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.tar.xz
yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.tar.zst
yuzu-0b2798be276941fb5ee9df346b5a566c29cea4ed.zip
-rw-r--r--src/common/settings.cpp19
1 files changed, 16 insertions, 3 deletions
diff --git a/src/common/settings.cpp b/src/common/settings.cpp
index 66dffc9bf..6cbbea1b2 100644
--- a/src/common/settings.cpp
+++ b/src/common/settings.cpp
@@ -1,8 +1,11 @@
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include <version>
#if __cpp_lib_chrono >= 201907L
#include <chrono>
+#include <exception>
+#include <stdexcept>
#endif
#include <string_view>
@@ -25,9 +28,19 @@ std::string GetTimeZoneString() {
if (time_zone_index == 0) { // Auto
#if __cpp_lib_chrono >= 201907L
const struct std::chrono::tzdb& time_zone_data = std::chrono::get_tzdb();
- const std::chrono::time_zone* current_zone = time_zone_data.current_zone();
- std::string_view current_zone_name = current_zone->name();
- location_name = current_zone_name;
+ try {
+ const std::chrono::time_zone* current_zone = time_zone_data.current_zone();
+ std::string_view current_zone_name = current_zone->name();
+ location_name = current_zone_name;
+ } catch (std::runtime_error& runtime_error) {
+ // VCRUNTIME will throw a runtime_error if the operating system's selected time zone
+ // cannot be found
+ location_name = Common::TimeZone::FindSystemTimeZone();
+ LOG_WARNING(Common,
+ "Error occurred when trying to determine system time zone:\n{}\nFalling "
+ "back to hour offset \"{}\"",
+ runtime_error.what(), location_name);
+ }
#else
location_name = Common::TimeZone::FindSystemTimeZone();
#endif